#include <iostream>

class Solution
{
public:
    static const int MonthDay[];
    int main()
    {
        int year, month;
        std::cin >> year >> month;
        if (month == 2)
        {
            if ((year % 100 != 0 && year % 4 == 0) || year % 400 == 0)
            {
                std::cout << 29;
            }
            else
            {
                std::cout << 28;
            }
        }
        else
        {
            std::cout << MonthDay[month];
        }
        return 0;
    }
};

const int Solution::MonthDay[] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};

#ifndef __LOCAL_TEST__
int main()
{
    return Solution().main();
}
#endif